<template>
	<uni-calendar :date="now_date" :insert="true" :lunar="true" :start-date="start_date" :end-date='end_date'
		@change="change" @confirm="confirm" />
</template>

<script>
	import {
		dateFtt
	} from '@/utils/tools.js'
	export default {
		data() {
			return {
				start_date: '',
				end_date: '',
				now_date: '',
			};
		},
		onLoad(props) {
			let dateListItem = JSON.parse(decodeURIComponent(props.dateListItem))
			console.log(dateListItem)
			if (dateListItem && Object.keys(dateListItem).length > 0) {
				let _date = dateListItem._date;
				let end_date = dateListItem.end_date;
				this.now_date = dateFtt("yyyy-MM-dd", new Date(_date))
				this.start_date = dateFtt("yyyy-MM-dd", new Date())
				this.end_date = dateFtt("yyyy-MM-dd", new Date(end_date))
				console.log(end_date)
				console.log(this.end_date)
			} else {
				const date = new Date()
				this.now_date = dateFtt("yyyy-MM-dd", new Date())
				this.start_date = dateFtt("yyyy-MM-dd", new Date())
			}

		},
		methods: {
			change(e) {
				this.$api.prePage().setDateList({
					date: `${e.month}-${e.date}`,
					_date: e.fulldate,
					type: 1
				})
				uni.navigateBack()
			},
			confirm(e) {
				console.log(e)
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>